<?php
// +----------------------------------------------------------------------
// | ThinkPHP [ WE CAN DO IT JUST THINK ]
// +----------------------------------------------------------------------
// | Copyright (c) 2006~2018 http://thinkphp.cn All rights reserved.
// +----------------------------------------------------------------------
// | Licensed ( http://www.apache.org/licenses/LICENSE-2.0 )
// +----------------------------------------------------------------------
// | Author: liu21st <liu21st@gmail.com>
// +----------------------------------------------------------------------
use think\facade\Route;

Route::rest([
    'update' => ['PUT', '', 'update'],
    'delete' => ['DELETE', '', 'del'],
]);

$ns = '\app\controller\\';

Route::group(function(){
    Route::get('info', 'Index@info');
    Route::get('captcha', 'Index@captcha');
    Route::post('file/upload', 'File@upload');
    Route::post('file/multi', 'File@multi');
    Route::get('cate', 'Cate@index'); // 支付回调
    Route::get('city/tree', 'City@tree');
    Route::resource('city', 'City')->only(['index']);
    Route::resource('sms', 'Sms')->only(['save'])->middleware('throttle', [
        'visit_rate' => '10/m'
    ]);
    Route::resource('help', 'Help')->only(['index', 'read']);
    Route::post('weapp/decode', 'Weapp@decode'); // 小程序解密
    Route::get('weapp/session', 'Visitor@session'); // 获取session
})->prefix($ns)->middleware('format')->crossDomainRule();

Route::post('file/editor', 'File@editor')->prefix($ns)->crossDomainRule();
Route::post('wepay/notify', 'Wepay@notify')->prefix($ns); // 微信支付回调
Route::post('alipay/notify', 'Alipay@notify')->prefix($ns); // 支付宝回调

// Route::get('upload/:name', 'Image/read')->prefix($ns)->pattern(['name' => '[\w\d|\/\-]+'])->ext('jpg|jpeg|png')->crossDomainRule(); // 查看图片

Route::miss($ns . 'Error@index')->crossDomainRule();
